package com.lanou.cart.controller;

import com.lanou.cart.service.OrderCartService;
import com.lanou.entity.entity.CartItem;
import com.lanou.entity.entity.TempEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 创建人   :卢松
 * 创建时间 :2019-07-17
 **/
@Controller
@RequestMapping("/orderCart")
public class OrderCartController {


    @Resource
    private OrderCartService orderCartService;

//    这里假设一个用户ID
    private String id = "userID:7";

    @PostMapping("/find")
    public List find(){

        return null;
    }

    @PostMapping("/sendItems")
    @ResponseBody
    public Integer keepItemsData(@RequestBody TempEntity tempEntity){

        for (Long aLong : tempEntity.getArray()) {
            System.out.println("+++:"+aLong);
        }

        Integer integer = this.orderCartService.keepItemData(tempEntity.getArray(), this.id);

        return integer;
    }

    @PostMapping("/findCartItemList")
    public List findCartItemList(){
        return null;
    }

    @GetMapping("/getItemData")
    @ResponseBody
    public List<CartItem> getItemData(){

        List<CartItem> cartItemList = this.orderCartService.getItemData(this.id);
        return cartItemList;
    }


}
